package org.cuit.lmq.utils;


import org.cuit.lmq.domain.dto.PageDto;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Seon
 * @date 2022/12/3 18:18
 */
public class PageHelperUtil {
    /**
     * 获取计算的分页数据,根据传入的pageDto来返回对应分页的开始和结束的begin和end数据
     *
     * @return map 其中键值为{begin}和{end}
     */
    public static Map<String, Object> getPageData(PageDto pageDto) {
        Integer currentPage = pageDto.getCurrentPage();
        Integer pageSize = pageDto.getPageSize();
        Map<String, Object> pageData = new HashMap<>();
        Integer begin = (currentPage - 1) * pageSize;
        Integer end = begin + pageSize;
        pageData.put("begin", begin);
        pageData.put("end", end);
        return pageData;
    }
}
